package com.industrial.premu.service.impl;

import java.util.List;
import java.util.Set;

import com.industrial.common.core.utils.DateUtils;
import com.industrial.common.security.utils.SecurityUtils;
import com.industrial.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.industrial.premu.mapper.PreMuBenefitEvaluationAppealMapper;
import com.industrial.premu.domain.PreMuBenefitEvaluationAppeal;
import com.industrial.premu.service.IPreMuBenefitEvaluationAppealService;

/**
 * 企业数据申诉-状态Service业务层处理
 * 
 * @author zhous
 * @date 2024-01-26
 */
@Service
public class PreMuBenefitEvaluationAppealServiceImpl implements IPreMuBenefitEvaluationAppealService 
{
    @Autowired
    private PreMuBenefitEvaluationAppealMapper preMuBenefitEvaluationAppealMapper;

    /**
     * 查询企业数据申诉-状态
     * 
     * @param id 企业数据申诉-状态主键
     * @return 企业数据申诉-状态
     */
    @Override
    public PreMuBenefitEvaluationAppeal selectPreMuBenefitEvaluationAppealById(String id)
    {
        return preMuBenefitEvaluationAppealMapper.selectPreMuBenefitEvaluationAppealById(id);
    }

    /**
     * 查询企业数据申诉-状态列表
     * 
     * @param preMuBenefitEvaluationAppeal 企业数据申诉-状态
     * @return 企业数据申诉-状态
     */
    @Override
    public List<PreMuBenefitEvaluationAppeal> selectPreMuBenefitEvaluationAppealList(PreMuBenefitEvaluationAppeal preMuBenefitEvaluationAppeal)
    {

        LoginUser loginUser = SecurityUtils.getLoginUser();
        Set<String> roles= loginUser.getRoles();
        if(roles.contains("q_01_001")){
            preMuBenefitEvaluationAppeal.setUscc(loginUser.getUsername());
        }else if(roles.contains("x_01_011")||roles.contains("along_yellow_river")||roles.contains("n_r_p_b")||
                roles.contains("conservancy_bureau")||roles.contains("taxation_bureau")||roles.contains("human_resources")
                ||roles.contains("bureau_statistics") ||roles.contains("ecological_bureau")
        ){
            String county=  loginUser.getSysUser().getDistrict();
            preMuBenefitEvaluationAppeal.setCounty(county);
        }else if(roles.contains("s_01_011")){
            String city=  loginUser.getSysUser().getCity();
            preMuBenefitEvaluationAppeal.setCity(city);
        }else if(roles.contains("p_01_011")){
            String province=  loginUser.getSysUser().getProvince();
            preMuBenefitEvaluationAppeal.setProvince(province);
        }
        return preMuBenefitEvaluationAppealMapper.selectPreMuBenefitEvaluationAppealList(preMuBenefitEvaluationAppeal);
    }

    /**
     * 新增企业数据申诉-状态
     * 
     * @param preMuBenefitEvaluationAppeal 企业数据申诉-状态
     * @return 结果
     */
    @Override
    public int insertPreMuBenefitEvaluationAppeal(PreMuBenefitEvaluationAppeal preMuBenefitEvaluationAppeal)
    {
        preMuBenefitEvaluationAppeal.setCreateTime(DateUtils.getNowDate());
        return preMuBenefitEvaluationAppealMapper.insertPreMuBenefitEvaluationAppeal(preMuBenefitEvaluationAppeal);
    }

    /**
     * 修改企业数据申诉-状态
     * 
     * @param preMuBenefitEvaluationAppeal 企业数据申诉-状态
     * @return 结果
     */
    @Override
    public int updatePreMuBenefitEvaluationAppeal(PreMuBenefitEvaluationAppeal preMuBenefitEvaluationAppeal)
    {
        return preMuBenefitEvaluationAppealMapper.updatePreMuBenefitEvaluationAppeal(preMuBenefitEvaluationAppeal);
    }

    /**
     * 批量删除企业数据申诉-状态
     * 
     * @param ids 需要删除的企业数据申诉-状态主键
     * @return 结果
     */
    @Override
    public int deletePreMuBenefitEvaluationAppealByIds(String[] ids)
    {
        return preMuBenefitEvaluationAppealMapper.deletePreMuBenefitEvaluationAppealByIds(ids);
    }

    /**
     * 删除企业数据申诉-状态信息
     * 
     * @param id 企业数据申诉-状态主键
     * @return 结果
     */
    @Override
    public int deletePreMuBenefitEvaluationAppealById(String id)
    {
        return preMuBenefitEvaluationAppealMapper.deletePreMuBenefitEvaluationAppealById(id);
    }

    @Override
    public PreMuBenefitEvaluationAppeal selectPreMuBenefitEvaluationAppealByAppealId(String appealId) {
        return preMuBenefitEvaluationAppealMapper.selectPreMuBenefitEvaluationAppealByAppealId(appealId);
    }
}
